import { stringify } from 'qs';
import request from '../utils/request';

// <!---------------------------------------- 平台字典管理 ------------------------------>

// 获取平台字典列表
export async function platformDictList(page) {
  return request(`/apis/auth/platform/dict?${stringify(page)}`);
}

//新增平台字典列表
export async function savePlatformDict(list) {
  return request(`/apis/auth/platform/dict`, {
    method: 'POST',
    body: {
      ...list,
    },
  });
}

// 获取
export async function platformDictAllList() {
  return request(`/apis/auth/platform/dict/all`);
}

//通过id获取字典信息
export async function getPlatformDictId(id) {
  return request(`/apis/auth/platform/dict/${id}`);
}

//修改对应id的字典信息
export async function updatePlatformDictId(list) {
  return request(`/apis/auth/platform/dict/${list.id}`, {
    method: 'PUT',
    body: {
      ...list,
    },
  });
}

//检查新增小类的数据格式 防重

export async function checkDict(list) {
  return request(`/apis/auth/platform/dict/check/code`, {
    method: 'POST',
    body: {
      ...list,
    },
  });
}

//删除字典
export async function deleteDict(ids) {
  return request(`/apis/auth/platform/dict/${ids}`, {
    method: 'DELETE',
    // body: {
    //   ...ids,
    // },
  });
}

//获取字典查询项
export async function getDictType() {
  return request(`/apis/auth/platform/dict/type`);
}

//根据字典大类查询
export async function searchDictByType(type) {
  return request(`/apis/auth/platform/dict/${stringify(type)}`);
}

//上移
export async function upSort(id) {
  return request(`/apis/auth/platform/dict/${id}/upSort`);
}

//下移
export async function downSort(id) {
  return request(`/apis/auth/platform/dict/${id}/downSort`);
}

// <!---------------------------------------- 站点字典管理 ------------------------------>

// 获取站点字典列表
export async function getOemDictList(page) {
  return request(`/apis/auth/oem/dict?${stringify(page)}`);
}

//通过id获取站点字典信息
export async function getOemDictId(id) {
  return request(`/apis/auth/oem/dict/${id}`);
}

// 获取大类列表
export async function oemFindType() {
  return request(`/apis/auth/oem/dict/findType`);
}

//修改站点字典
export async function updateDictList(list) {
  return request(`/apis/auth/oem/dict/${list.id}`, {
    method: 'PUT',
    body: {
      ...list,
    },
  });
}

//一键还原
export async function recoverySingleById(id) {
  return request(`/apis/auth/oem/dict/recoverySingleById/${id}`);
}

//检查站点字典数据格式 防重
export async function checkOemDict(list) {
  return request(`/apis/auth/oem/dict/check/code`, {
    method: 'POST',
    body: {
      ...list,
    },
  });
}

//新增站点字典
export async function saveOemDict(list) {
  return request(`/apis/auth/oem/dict`, {
    method: 'POST',
    body: {
      ...list,
    },
  });
}


//还原站点
export async function updateByStationId(stationId) {
  return request(`/apis/auth/oem/dict/updateByStationId?${stringify(stationId)}`);
}

//上移
export async function upSorOem(id) {
  return request(`/apis/auth/oem/dict/${id}/upSort`);
}

//下移
export async function downSortOem(id) {
  return request(`/apis/auth/oem/dict/${id}/downSort`);
}
